@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-card';
@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-element';

$sizes: 's', 'm', 'l';

.functionBadgeWrapper {
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;

  display: none;

  &[data-visible] {
    display: block;
  }
}

.composition {
  @include composite-var($card-composition-container);

  box-sizing: border-box;
  height: 100%;
}

.contentWrapper {
  position: relative;
  height: 100%;
}

.card {
  @include composite-var($card-container);

  position: relative;
  z-index: 0;

  overflow: hidden;
  display: flex;
  flex-direction: column;

  box-sizing: border-box;
  margin: 0;
  padding: 0;

  text-align: left;

  background-color: $sys-neutral-background1-level;
  border: 0;
  outline-color: transparent;

  &:hover {
    .functionBadgeWrapper {
      display: block;
    }
  }

  &[data-outline] {
    @include outline-var($container-focused-s);

    outline-color: $sys-neutral-decor-default;
    outline-width: $border-width-card-container;
  }

  &:hover,
  &:focus-visible {
    --snack-ui-card-background-color: #{$sys-neutral-background2-level};
  }

  &:focus-visible {
    @include outline-var($container-focused-l);

    background-color: $sys-neutral-background2-level;
    outline-color: $sys-primary-accent-default;

    .functionBadgeWrapper {
      display: block;
    }

    .check {
      background-color: $sys-primary-accent-default;
    }
  }

  &:focus-within {
    .functionBadgeWrapper {
      display: block;
    }
  }

  &[data-checked] {
    @include outline-var($container-focused-s);

    outline-color: $sys-primary-decor-activated;
    outline-width: $border-width-card-container;

    &:hover {
      outline-color: $sys-primary-decor-hovered;
      box-shadow: none;
    }

    .contentWrapper::before {
      content: '';

      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;

      opacity: $opacity-a008;
      background-color: $sys-primary-accent-default;
    }

    .check {
      color: $sys-primary-on-accent;
      background-color: $sys-primary-accent-default;
    }
  }

  &[data-checked]:focus-visible {
    @include outline-var($container-focused-l);

    outline-color: $sys-primary-accent-default;

    .check {
      color: $sys-primary-on-accent;
      background-color: $sys-primary-accent-default;
    }
  }

  &[data-disabled] {
    @include outline-var($container-focused-s);

    cursor: not-allowed;
    background-color: $sys-neutral-background;
    outline-color: $sys-neutral-decor-default;
    outline-width: $border-width-card-container;

    &[data-checked] {
      .check {
        color: $sys-neutral-on-accent;
        background-color: $sys-neutral-text-disabled;
      }
    }

    * {
      cursor: not-allowed;
    }
  }

  &[data-pointer] {
    * {
      cursor: pointer;
    }

    &[data-outline] {
      &:hover {
        outline-color: $sys-neutral-decor-hovered;
        box-shadow: none;
      }

      &:focus-visible {
        @include outline-var($container-focused-l);

        outline-color: $sys-primary-accent-default;
      }
    }

    &:hover {
      box-shadow: simple-var($theme-variables, 'box-shadow', 'elevation', 'level2');
    }
  }

  &[data-pointer][data-disabled] {
    * {
      cursor: not-allowed;
    }
  }
}

.anchor {
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;

  border-radius: $radius-card-container;
}

.body {
  display: block;
  flex-grow: 1;
  flex-shrink: 1;

  width: 100%;

  color: $sys-neutral-text-support;
  text-align: initial;
}

.content {
  position: relative;

  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;

  box-sizing: border-box;
  max-width: 100%;
  height: 100%;

  @each $size in $sizes {
    &[data-size='#{$size}'] {
      @include composite-var($card, 'content', $size, 'container');
    }
  }
}

.footer {
  position: relative;
  box-sizing: border-box;
  width: 100%;
}
